﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using ShadowCommando.Game.Utilites;
namespace ShadowCommando.Game.Elements
{
    /// <summary>
    /// Klasa reprezentująca postacie dziedziczą po niej Enemy oraz Hero
    /// </summary>
   public class Character:Element
    {
       /// <summary>
       /// Konstruktor
       /// </summary>
       /// <param name="_step"></param>
       /// <param name="_diff"></param>
        public Character(int _step,LevelDifficulty _diff):base(_step,_diff)
        {
            weapons=new List<Weapon>();
            maxLife = 100;//dodacdo res;
            maxArmor = 100;
        }
        #region Items
       /// <summary>
       /// Maxymalne życie
       /// </summary>
       protected int maxLife;
       /// <summary>
       /// Maxymalny pancerz
       /// </summary>
       protected int maxArmor;
        /// <summary>
        /// Lista posiadanych broni
        /// </summary>
        protected List<Weapon> weapons;
       /// <summary>
       /// Aktualna broń
       /// </summary>
        protected Weapon actualWeapon;
        #endregion
        #region Properties
       /// <summary>
       /// Maxymalne życie
       /// </summary>
       public int MaxLife
       {
           get { return maxLife; }
            
       }
       /// <summary>
       /// Maxymalny pancerz
       /// </summary>
       public int MaxArmor
       {
           get { return maxArmor; }
       }
       /// <summary>
       /// Lista posiadanych broni
       /// </summary>
        public List<Weapon> Weapons
        {
            get
            {
                return weapons;
            }
            set
            {
                weapons = value;
            }
        }
       /// <summary>
       /// Aktualna broń
       /// </summary>
        public Weapon ActualWeapon
        {
            get
            {
                return actualWeapon;
            }
            set
            {
                actualWeapon = value;
            }

        }
        #endregion
        #region Functions

       /// <summary>
       /// Strzał
       /// </summary>
       /// <param name="p1"></param>
       /// <returns></returns>
        public Bullet Shot(Point p1)
        {
            if (actualWeapon.BulletCount != 0)
            {
                actualWeapon.BulletCount--;
                return actualWeapon.Shot(p1, new Point(FakeX, FakeY), cos, sin);
            }
            return null;
        }
       /// <summary>
       /// Strzał do sprawdzenia
       /// </summary>
       /// <param name="p1">Pnkt docelowy</param>
       /// <returns></returns>
        public Bullet ShotToCheck(Point p1)
        {
            actualWeapon.BulletCount++;

            return actualWeapon.Shot(p1, new Point(FakeX + Width / 2, FakeY + Height / 2), cos, sin);
        }
       /// <summary>
       /// Zmień broń
       /// </summary>
        public  void ChangeWeapon()
        {
            int index = weapons.IndexOf(actualWeapon);
            index = (index + 1) % weapons.Count;
            actualWeapon = weapons[index];
        }
        #endregion
    }
}
